﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Company.Database.Base.Entities;
using System.Text.Json.Serialization;

namespace Company.Application.Share.Entities
{
    /// <summary>
    /// 工作站实体
    /// </summary>
    public class StationEntity
    {
        public int Id { get; set; }
        /// <summary>
        /// 工作站点名称
        /// </summary>
        public string? Name { get; set; }
        /// <summary>
        /// 所属医院ID
        /// </summary>
        public int HospitalId { get; set; }
        /// <summary>
        /// 物理位置
        /// </summary>
        public string? Position { get; set; }
        /// <summary>
        /// MAC
        /// </summary>
        public string? MacAddress { get; set; }
        /// <summary>
        /// IP
        /// </summary>
        public string? IPAddress { get; set; }
        /// <summary>
        /// 是否启用，0=启用，1=停用
        /// </summary>
        public int Status { get; set; }

        [JsonIgnore]
        public ObservableCollection<DeviceEntity> Children { get; } = new();
        public static readonly object locker = new object();
        public void Add(DeviceEntity entity)
        {
            lock (locker)
            {
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    Children.Add(entity);
                }));
            }
        }

    }
}
